#ifndef FUEL_REFUND_STRUCT_HH
#define FUEL_REFUND_STRUCT_HH 1


#include <string>
#include <iostream>
#include <vector>
#include "otl8.hpp"
#include "datetime_period.hpp"

static const char*  fuel_refund_struct_s = "SELECT ID, RANGE_ID, FUEL_ID, AMOUNT, FROMDATE, TODATE FROM FUEL_REFUND_STRUCT";

static const char*  fuel_refund_struct_i = "INSERT INTO FUEL_REFUND_STRUCT ( ID, RANGE_ID, FUEL_ID, AMOUNT, FROMDATE, TODATE )VALUES(:f1<int>, :f2<int>, :f3<int>, :f4<double>, :f5<date>, :f6<date>)";

static const char* fuel_refund_struct_c = "CREATE TABLE FUEL_REFUND_STRUCT ( ID INTEGER , RANGE_ID INTEGER , FUEL_ID INTEGER , AMOUNT FLOAT , FROMDATE  , TODATE  )";
class fuel_refund_struct
{



public:
fuel_refund_struct():_id(0), _range_id(0), _fuel_id(0), _amount(0), _fromDate(boost::gregorian::not_a_date_time), _toDate(boost::gregorian::not_a_date_time){_select=fuel_refund_struct_s;_insert=fuel_refund_struct_i;_create=fuel_refund_struct_c;}


fuel_refund_struct(int a__id, int a__range_id, int a__fuel_id, float a__amount, boost::gregorian::date a__fromDate, boost::gregorian::date a__toDate):_id(a__id) , _range_id(a__range_id) , _fuel_id(a__fuel_id) , _amount(a__amount) , _fromDate(a__fromDate) , _toDate(a__toDate) {_select=fuel_refund_struct_s;_insert=fuel_refund_struct_i;_create=fuel_refund_struct_c;}


int id(){return  _id;}
void set_id(int a__id){ _id = a__id;}


int range_id(){return  _range_id;}
void set_range_id(int a__range_id){ _range_id = a__range_id;}


int fuel_id(){return  _fuel_id;}
void set_fuel_id(int a__fuel_id){ _fuel_id = a__fuel_id;}


float amount(){return  _amount;}
void set_amount(float a__amount){ _amount = a__amount;}


boost::gregorian::date fromDate(){return  _fromDate;}
void set_fromDate(boost::gregorian::date a__fromDate){ _fromDate = a__fromDate;}


boost::gregorian::date toDate(){return  _toDate;}
void set_toDate(boost::gregorian::date a__toDate){ _toDate = a__toDate;}


fuel_refund_struct & operator=( const fuel_refund_struct & x)
{
	_id =  x._id;
	_range_id =  x._range_id;
	_fuel_id =  x._fuel_id;
	_amount =  x._amount;
	_fromDate =  x._fromDate;
	_toDate =  x._toDate;
	return *this;
}


bool operator==( const fuel_refund_struct & x)
{
	return 	_id ==  x._id &&
	_range_id ==  x._range_id &&
	_fuel_id ==  x._fuel_id &&
	_amount ==  x._amount &&
	_fromDate ==  x._fromDate &&
	_toDate ==  x._toDate;
}


friend std::istream& operator >> (std::istream& ist, fuel_refund_struct & t)
{
	if (!(ist >> t._id)) return ist;
	if (!(ist >> t._range_id)) return ist;
	if (!(ist >> t._fuel_id)) return ist;
	if (!(ist >> t._amount)) return ist;
	if (!(ist >> t._fromDate)) return ist;
	if (!(ist >> t._toDate)) return ist;

	return ist;
}

friend std::ostream& operator << (std::ostream& ost, fuel_refund_struct & t)
{
	ost << t._id << " ";
	ost << t._range_id << " ";
	ost << t._fuel_id << " ";
	ost << t._amount << " ";
	ost << t._fromDate << " ";
	ost << t._toDate << " ";

	return ost;
}

/*
friend otl_stream& operator >> (otl_stream& ist, fuel_refund_struct & t)
{
	ist >> t._id;
	ist >> t._range_id;
	ist >> t._fuel_id;
	ist >> t._amount;
	ist >> t._fromDate;
	ist >> t._toDate;

	return ist;
}

friend otl_stream& operator << (otl_stream& ost, fuel_refund_struct & t)
{
	ost << t._id ;
	ost << t._range_id ;
	ost << t._fuel_id ;
	ost << t._amount ;
	ost << t._fromDate ;
	ost << t._toDate ;

	return ost;
}
*/

std::string select_stmt() { return _select; }
std::string insert_stmt() { return _insert; }
std::string create_stmt() { return _create; }


private:

	int	_id;
	int	_range_id;
	int	_fuel_id;
	float	_amount;
	boost::gregorian::date	_fromDate;
	boost::gregorian::date	_toDate;
	std::string _create;
	std::string _select;
	std::string _insert;
char buf[128];
};
#endif
